package com.ipet.app.util;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
 * Created by jindongping on 16/3/22.
 * 用于调整recycleVeiw 间距的类
 */
public class SpaceItemDecoration extends RecyclerView.ItemDecoration {

    private int topSpace;
    private int rightSpace;

    public SpaceItemDecoration(int topSpace) {
        this.topSpace = TDevice.dipToPx(topSpace);
    }

    public SpaceItemDecoration(int topSpace, int rightSpace) {
        this.topSpace = TDevice.dipToPx(topSpace);
        this.rightSpace = TDevice.dipToPx(rightSpace);
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {

        if (parent.getChildPosition(view) != 0) {
            outRect.top = topSpace;
            outRect.right = rightSpace;
        }
    }
}